# import  time
#
# print(dir(time))
#
# start = time.time()
# print("开始执行时间time.time() ",start)
# # for i in range(1000):
# #     pass
#
#
# # 模拟很长点时间
# time.sleep(5) #线程休眠
#
# end = time.time();
# print("开始执行时间time.time() ",end)
#
# print("执行的时间",str(end-start))

import  datetime
print(dir(datetime))

from datetime import  date
print("datetime.date",dir(datetime.date))
print("datetime.datetime",dir(datetime.datetime))
print("datetime.time",dir(datetime.time))
print("datetime.timezone",dir(datetime.timezone))
# 获取当前时间
print("datetime.datetime.now()",datetime.datetime.now())
# datetime 包含年月日 时分秒
print("datetime.datetime.now().year",datetime.datetime.now().year)
print("datetime.datetime.now().month",datetime.datetime.now().month)
print("datetime.datetime.now().day",datetime.datetime.now().day)
print("datetime.datetime.now().hour",datetime.datetime.now().hour)
print("datetime.datetime.now().minute",datetime.datetime.now().minute)
print("datetime.datetime.now().second",datetime.datetime.now().second)



from datetime import timedelta
now = datetime.datetime.now();
before = now + timedelta(days=-1)
print("before",before)

#格式化日期 yyyy年M月D日  16时01分55秒
# f format 有日期 转换成字符串
#p parse   从字符串转日期
print(datetime.datetime.now().strftime('%H:%M:%S %Y/%m/%d'))


newsTime='Sun, 23 Apr 2017 05:15:05 GMT'

GMT_FORMAT = '%a, %d %b %Y %H:%M:%S GMT'
# 从字符串转日期，日期可以参与运算
print(type(datetime.datetime.strptime(newsTime,GMT_FORMAT)))


